package com.kwedding.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.kwedding.dto.web.RequestWebAddDemo;
import com.kwedding.dto.web.RequestWebDemoList;
import com.kwedding.dto.web.RequestWebUpDownDemo;
import com.kwedding.dto.web.RequestWebUpdateDemo;
import com.kwedding.dto.web.ResponseWebDemoList;
import com.kwedding.service.web.WebDemoService;
import com.kwedding.util.BackJson;
import com.kwedding.util.JsonBack;
import com.kwedding.util.JsonBackBase;
import com.kwedding.util.LoggerParent;
import com.kwedding.util.Resp_PageInfo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Controller
@RequestMapping("/rest/web/demo")
@Api(tags = "WebDemo")
public class WebDemoController extends LoggerParent {

	@Autowired
	private WebDemoService webDemoService;

	@ApiOperation("添加样片")
	@ResponseBody
	@RequestMapping(value = "insert", method = { RequestMethod.POST })
	private JsonBackBase insert(@RequestBody RequestWebAddDemo addBusiness) {
		webDemoService.insert(addBusiness);
		return BackJson.success();
	}

	@ApiOperation("修改样片")
	@ResponseBody
	@RequestMapping(value = "update", method = { RequestMethod.POST })
	private JsonBackBase update(@RequestBody RequestWebUpdateDemo requestWebUpdateDemo) {
		webDemoService.update(requestWebUpdateDemo);
		return BackJson.success();
	}

	@ApiOperation("获取样片列表")
	@ResponseBody
	@RequestMapping(value = "getDemoList", method = { RequestMethod.POST })
	private JsonBackBase<Resp_PageInfo<ResponseWebDemoList>> getDemoList(
			@RequestBody RequestWebDemoList requestWebDemoList) {
		return BackJson.successObj(webDemoService.getDemoList(requestWebDemoList));
	}

	@ApiOperation("上下架样片")
	@ResponseBody
	@RequestMapping(value = "upDownDemo", method = { RequestMethod.POST })
	private JsonBack upDownDemo(@RequestBody RequestWebUpDownDemo upDownDemo) {
		webDemoService.upDownDemo(upDownDemo);
		return BackJson.success();
	}
}
